﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.AvalonEdit.Document;
using tiDE.Panels;
using tiDE.Assembly;

namespace tiDE.Support.CodeInsight
{
    public class z80CodeInsight : ICodeInsightProvider
    {
        public string[] GetExtensions()
        {
            return new string[] { ".z80", ".asm" };
        }

        public string GetName()
        {
            return "z80";
        }

        public Breakpoint GetBreakpointForLine(string Line)
        {
            int startIndex = 0;
            int length = Line.Length;
            Line = Line.TrimStart();
            startIndex += length - Line.Length;
            Line = Line.TrimEnd();
            length = Line.Length;
            Line = Assembler.StripComments(Line);
            if (Line.Contains("\\"))
                Line = Line.Remove(Line.IndexOf("\\")); // TODO: Strings/chars
            Line = Line.TrimEnd();
            length = Line.Length;

            return new Breakpoint()
            {
                StartOffset = startIndex,
                EndOffset = startIndex + length,
                Length = length,
                Active = false,
                Enabled = true,
            };
        }
    }
}
